﻿// Decompiled with JetBrains decompiler
// Type: System.Web.Razor.Parser.HtmlLanguageCharacteristics
// Assembly: System.Web.Razor, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35
// MVID: 682513D6-F37E-48AC-9909-F3EE103CFF14
// Assembly location: D:\Project\Idea\无人机外网\uav\客户端工程\排查工具\bin\Release\System.Web.Razor.dll

using System.Collections.Generic;
using System.Web.Razor.Parser.SyntaxTree;
using System.Web.Razor.Resources;
using System.Web.Razor.Text;
using System.Web.Razor.Tokenizer;
using System.Web.Razor.Tokenizer.Symbols;

namespace System.Web.Razor.Parser
{
  /// <summary>This type/member supports the .NET Framework infrastructure and is not intended to be used directly from your code.Represents the different language characteristics in an html.</summary>
  public class HtmlLanguageCharacteristics : 
    LanguageCharacteristics<HtmlTokenizer, HtmlSymbol, HtmlSymbolType>
  {
    private static readonly HtmlLanguageCharacteristics _instance = new HtmlLanguageCharacteristics();

    private HtmlLanguageCharacteristics()
    {
    }

    /// <summary>This type/member supports the .NET Framework infrastructure and is not intended to be used directly from your code.Gets the instance for the <see cref="T:System.Web.Razor.Parser.HtmlLanguageCharacteristics" /> class.</summary>
    /// <returns>The instance for the <see cref="T:System.Web.Razor.Parser.HtmlLanguageCharacteristics" /> class.</returns>
    public static HtmlLanguageCharacteristics Instance => HtmlLanguageCharacteristics._instance;

    /// <summary>This type/member supports the .NET Framework infrastructure and is not intended to be used directly from your code.Gets a sample symbol in the html.</summary>
    /// <returns>A sample symbol in the html.</returns>
    /// <param name="type">The <see cref="T:System.Web.Razor.Tokenizer.Symbols.HtmlSymbolType" />.</param>
    public override string GetSample(HtmlSymbolType type)
    {
      switch (type)
      {
        case HtmlSymbolType.Text:
          return RazorResources.HtmlSymbol_Text;
        case HtmlSymbolType.WhiteSpace:
          return RazorResources.HtmlSymbol_WhiteSpace;
        case HtmlSymbolType.NewLine:
          return RazorResources.HtmlSymbol_NewLine;
        case HtmlSymbolType.OpenAngle:
          return "<";
        case HtmlSymbolType.Bang:
          return "!";
        case HtmlSymbolType.Solidus:
          return "/";
        case HtmlSymbolType.QuestionMark:
          return "?";
        case HtmlSymbolType.DoubleHyphen:
          return "--";
        case HtmlSymbolType.LeftBracket:
          return "[";
        case HtmlSymbolType.CloseAngle:
          return ">";
        case HtmlSymbolType.RightBracket:
          return "]";
        case HtmlSymbolType.Equals:
          return "=";
        case HtmlSymbolType.DoubleQuote:
          return "\"";
        case HtmlSymbolType.SingleQuote:
          return "'";
        case HtmlSymbolType.Transition:
          return "@";
        case HtmlSymbolType.Colon:
          return ":";
        case HtmlSymbolType.RazorComment:
          return RazorResources.HtmlSymbol_RazorComment;
        case HtmlSymbolType.RazorCommentStar:
          return "*";
        case HtmlSymbolType.RazorCommentTransition:
          return "@";
        default:
          return RazorResources.Symbol_Unknown;
      }
    }

    /// <summary>This type/member supports the .NET Framework infrastructure and is not intended to be used directly from your code.Creates an html tokenizer.</summary>
    /// <returns>An html tokenizer.</returns>
    /// <param name="source">The source of the text document.</param>
    public override HtmlTokenizer CreateTokenizer(ITextDocument source) => new HtmlTokenizer(source);

    /// <summary>This type/member supports the .NET Framework infrastructure and is not intended to be used directly from your code.Flips the bracket symbol in the html.</summary>
    /// <returns>The bracket symbol in the html.</returns>
    /// <param name="bracket">The symbol bracket.</param>
    public override HtmlSymbolType FlipBracket(HtmlSymbolType bracket)
    {
      switch (bracket)
      {
        case HtmlSymbolType.OpenAngle:
          return HtmlSymbolType.CloseAngle;
        case HtmlSymbolType.LeftBracket:
          return HtmlSymbolType.RightBracket;
        case HtmlSymbolType.CloseAngle:
          return HtmlSymbolType.OpenAngle;
        case HtmlSymbolType.RightBracket:
          return HtmlSymbolType.LeftBracket;
        default:
          return HtmlSymbolType.Unknown;
      }
    }

    /// <summary>This type/member supports the .NET Framework infrastructure and is not intended to be used directly from your code.Creates a marker symbol in the Html.</summary>
    /// <returns>A marker symbol in the Html.</returns>
    /// <param name="location">The source location.</param>
    public override HtmlSymbol CreateMarkerSymbol(SourceLocation location) => new HtmlSymbol(location, string.Empty, HtmlSymbolType.Unknown);

    /// <summary>This type/member supports the .NET Framework infrastructure and is not intended to be used directly from your code.Gets the <see cref="T:System.Web.Razor.Tokenizer.Symbols.KnownSymbolType" /> in the html.</summary>
    /// <returns>The <see cref="T:System.Web.Razor.Tokenizer.Symbols.KnownSymbolType" /> in the html.</returns>
    /// <param name="type">The <see cref="T:System.Web.Razor.Tokenizer.Symbols.KnownSymbolType" />.</param>
    public override HtmlSymbolType GetKnownSymbolType(KnownSymbolType type)
    {
      switch (type)
      {
        case KnownSymbolType.WhiteSpace:
          return HtmlSymbolType.WhiteSpace;
        case KnownSymbolType.NewLine:
          return HtmlSymbolType.NewLine;
        case KnownSymbolType.Identifier:
          return HtmlSymbolType.Text;
        case KnownSymbolType.Keyword:
          return HtmlSymbolType.Text;
        case KnownSymbolType.Transition:
          return HtmlSymbolType.Transition;
        case KnownSymbolType.CommentStart:
          return HtmlSymbolType.RazorCommentTransition;
        case KnownSymbolType.CommentStar:
          return HtmlSymbolType.RazorCommentStar;
        case KnownSymbolType.CommentBody:
          return HtmlSymbolType.RazorComment;
        default:
          return HtmlSymbolType.Unknown;
      }
    }

    /// <summary>This type/member supports the .NET Framework infrastructure and is not intended to be used directly from your code.Creates a symbol in the Html.</summary>
    /// <returns>A symbol in the Html.</returns>
    /// <param name="location">The source location.</param>
    /// <param name="content">The content value.</param>
    /// <param name="type">The html symbol type.</param>
    /// <param name="errors">List of errors.</param>
    protected override HtmlSymbol CreateSymbol(
      SourceLocation location,
      string content,
      HtmlSymbolType type,
      IEnumerable<RazorError> errors)
    {
      return new HtmlSymbol(location, content, type, errors);
    }
  }
}
